package cn.yinzhiping.rabbbitmqlearn.direct;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 路由模式，routing 的 derict模式
 * @author yinzhiping
 */
@Component
public class RoutingDerictConsume {
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue, //临时队列
                    exchange = @Exchange(value="directs",type = "direct"),  //交换机
                    key = {"info","error"}
            )
    })
    public void recieveDirect1(String message){
        System.out.println("recieveDirect1接收到的消息："+message);
    }

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue, //临时队列
                    exchange = @Exchange(value="directs",type = "direct"),  //交换机
                    key = {"error","warn"}
            )
    })
    public void recieveDirect2(String message){
        System.out.println("recieveDirect1接收到的消息："+message);
    }
}
